package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/*
泛型
 */
public class GenericDemo {
    public static void main(String[] args) {
        Collection<Point> c=new ArrayList<>();
        c.add(new Point(1,2));
        c.add(new Point(3,4));
        c.add(new Point(5,5));
        c.add(new Point(6,7));
        Iterator<Point> it=c.iterator();
        while(it.hasNext()){
            Point p =it.next();
            System.out.println(p);
        }
        for(Point p:c){
            System.out.println(p);
        }







        /*
        Collection<String> c=new ArrayList<>();
        c.add("cxk");
        c.add("两年半");
        c.add("鸡");
        c.add("篮球");
        Iterator<String> it=c.iterator();
        while(it.hasNext()){
            String str=it.next();
            System.out.println(str);
        }// 类型  变量名 集合或数组
        for(String str:c){
            System.out.println(str);
        }

         */
    }
}
